package cloud.pangui.core.spring;

import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 初始化SpringUtils
 * 之所以放到listener中，是方便在beanRegist时就能拿到SpringUtils
 *
 * @Auther hepangui
 * @Date 2020/10/06 0001
*/
public class SpringUtilApplicationListener implements ApplicationListener<ApplicationPreparedEvent> {

	@Override
	public void onApplicationEvent(ApplicationPreparedEvent applicationEvent) {
		ConfigurableApplicationContext applicationContext = applicationEvent.getApplicationContext();
		SpringUtils.setApplicationContext(applicationContext);
	}
}
